//
//  HSDetailHomeWorkController.swift
//  HomeSchoolDemo
//
//  Created by rimi on 16/10/17.
//  Copyright © 2016年 赖虹宇. All rights reserved.
//

import UIKit

class HSDetailHomeWorkController: UITableViewController {
    let str = String()
    var objectiveBtn = UIButton()
    var directorBtn = UIButton()
    
    //数据源数组
    var dataArray : [HSDetailHomeWorkModel] = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //设置头部视图为导航栏
       tableView.tableHeaderView = setupTopUI()
      //获取数据
      loadData()
    }
    
    //获取数据
    fileprivate func loadData(){
        
        
    }
  

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return 0
    }

    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

        

        return cell
    }
  }
extension HSDetailHomeWorkController{
    //设置顶部UI
    func setupTopUI() -> UIView{
        //模拟一个假导航栏
        let navVc = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 114))
        navVc.backgroundColor = UIColor().colorWithHex(0x009ee7)
        view.addSubview(navVc)
        //返回按钮
        let back = UIButton(frame: CGRect(x: 8, y: 16, width: 70, height: 48))
        back.setImage(UIImage(named:"back"), for: .normal)
        back.addTarget(self, action: #selector(backBtnClicked), for: .touchUpInside)
        navVc.addSubview(back)
        //文字
        let label = UILabel(frame: CGRect(x: 60, y: 16, width: 150, height: 48))
        label.text = "作业标题"
        label.textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        label.font = UIFont.systemFont(ofSize: 20)
        navVc.addSubview(label)
        //客观题按钮
        objectiveBtn = UIButton(type: .custom)
        objectiveBtn.frame = CGRect(x: 0, y: 64, width: screenW/2, height: 50)
        objectiveBtn.setTitle("客观题", for: .normal)
        
        //未选中状态
        objectiveBtn.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
        //设置字体大小
        objectiveBtn.titleLabel?.font = UIFont.systemFont(ofSize: 19)
        
        //添加到导航栏上面
        navVc.addSubview(objectiveBtn)
        //点击事件
        objectiveBtn.addTarget(self, action: #selector(objectiveBtnClicked), for: .touchUpInside)
        
        
        //主观题按钮
        directorBtn = UIButton(type: .custom)
        directorBtn.frame = CGRect(x: screenW/2, y: 64, width: screenW/2, height: 50)
        directorBtn.setTitle("主观题", for: .normal)
        
        //未选中状态
        directorBtn.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
        //设置字体大小
        directorBtn.titleLabel?.font = UIFont.systemFont(ofSize: 19)
        
        //添加到导航栏上面
        navVc.addSubview(directorBtn)
        directorBtn.addTarget(self, action: #selector(directorBtnClicked), for: .touchUpInside)
        
        return navVc
    }
    //客观题按钮回调方法
    func objectiveBtnClicked(){
        print("点击了客观题")
        //改变两个按钮的显示颜色
        objectiveBtn.setTitleColor(#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), for: .normal)
        directorBtn.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
        
    }
    //主观题按钮回调方法
    func directorBtnClicked(){
        print("点击了主观题")
        //选中状态
        directorBtn.setTitleColor(#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), for: .normal)
        objectiveBtn.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
    }
    //返回按钮监听方法
    func backBtnClicked(){
        dismiss(animated: true, completion: nil)
    }

}
